<?php
require_once("/../ourDate.php");
require_once("/../resetDatabase.php");

class ourDateTest extends PHPUnit_Framework_TestCase
{
	public function testGetDateString()
	{
		$dateString = ourDate::getDateString();
		$this->assertEquals($dateString, "2011-12-05 8:00:00");
	}
	
	public function testGetDateSQL()
	{
		$dateSQL = ourDate::getDateSQL();
		$this->assertEquals($dateSQL, 1323068400);
	}
	
	public function testFormatDateTodayWithMinutes()
	{
		$time = array("2011-12-05 11:13:00",
					  "2011-12-05 11:13:02",
					  "2011/12/05 11:13:00",
					  "11:13:00 2011-12-05",
					  "11:13 2011-12-05",
					  "December 5th 2011 11:13",
					  "Dec 5 2011 11:13"
		);
	
		// Use multiple time formats as input.
		for($i = 0; $i < count($time); $i++)
		{
			$formattedDate = ourDate::formatDate($time[$i]);
			$this->assertEquals("Today 11:13am", $formattedDate);
		}
	}
	
	public function testFormatDateTodayOnTheHour()
	{
		$formattedDate = ourDate::formatDate("2011-12-05 21:00:00");
		$this->assertEquals("Today 9pm", $formattedDate);
	}
	
	public function testFormatDateTomorrowWithMinutes()
	{
		$formattedDate = ourDate::formatDate("2011-12-06 13:25:00");
		$this->assertEquals("Tomorrow 1:25pm", $formattedDate);
	}
	
	public function testFormatDateTomorrowOnTheHour()
	{
		$formattedDate = ourDate::formatDate("2011-12-06 13:00:00");
		$this->assertEquals("Tomorrow 1pm", $formattedDate);
	}
	
	public function testFormatDateGenericWithMinutes()
	{
		$formattedDate = ourDate::formatDate("2011-08-13 6:52:00");
		$this->assertEquals("Aug 13 @ 6:52am", $formattedDate);
	}

	public function testFormatDateGenericOnTheHour()
	{
		$formattedDate = ourDate::formatDate("2011-12-25 14:00:00");
		$this->assertEquals("Dec 25 @ 2pm", $formattedDate);
	}
	
	public function testEdgeCase()
	{
		$formattedDate = ourDate::formatDate("2011-12-06 00:00:00");
		$this->assertEquals("Tomorrow 12am", $formattedDate);
	}
}
?>